package com.itheima.buffer;

import com.itheima.domain.Student;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class Test3 {
    public static void main(String[] args) throws IOException {
//        	请按以下要求编写程序：
//
//		2).定义main()方法，定义一个存储Student的集合，并初始化一些数据：
//			List<Student> stuList = new ArrayList<>();
//			stuList.add(new Student(“迪丽热巴”,”女”,18,99);
//			stuList.add(new Student(“古力娜扎”,”女”,19,98);
//			stuList.add(new Student(“周杰伦”,”男”,20,88);
//			stuList.add(new Student(“蔡徐坤”,”男”,19,78);
//			/*
//			定义一个字符缓冲输出流BufferedWriter，将学员信息写入到”test3_4.txt”中，
//            每个学员信息占一行，每个字段之间用,符号隔开，例如：
//				迪丽热巴,女,18,99
//				古力娜扎,女,19,98
//				周杰伦,男,20,88
//				蔡徐坤,男,19,78
        List<Student> stuList = new ArrayList<>();
        stuList.add(new Student("迪丽热巴","女",18,99));
        stuList.add(new Student("古力娜扎","女",19,98));
        stuList.add(new Student("周杰伦","男",20,88));
        stuList.add(new Student("蔡徐坤","男",19,78));
        BufferedWriter bw = new BufferedWriter(new FileWriter("test3_4.txt"));
        String line;
        for (Student student : stuList) {
            bw.write(String.valueOf(student));
            bw.newLine();
        }
        bw.close();
    }
}
